import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './pages/home/home.component';
import { CakeComponent } from './pages/cake/cake.component';
import { AboutComponent } from './pages/about/about.component';
import { MineComponent } from './pages/mine/mine.component';
import { LoginComponent } from './login/login.component';
import { CollectComponent } from './my/collect/collect.component';
import { TransactionComponent } from './my/transaction/transaction.component';
import { InformationComponent } from './my/information/information.component';
import { MyCommentComponent } from './list/my-comment/my-comment.component';
import { PersonComponent } from './info/person/person.component';
import { AddressComponent } from './info/address/address.component';
import { ResetComponent } from './info/reset/reset.component';
import { WelcomeComponent } from './my/welcome/welcome.component';
import { CartComponent } from './cart/cart.component';
import { DetailsComponent } from './details/details.component';
import { DetailComponent } from './content/detail/detail.component';
import { CommentComponent } from './content/comment/comment.component';
import { ErrorComponent } from './error/error.component';
import { BreadComponent } from './pages/bread/bread.component';
import { RegisterComponent } from './register/register.component';
import { HistoryComponent } from './my/history/history.component';
import { MyOrderComponent } from './list/my-order/my-order.component';
import { OrderComponent } from './order/order.component';
import { OrderDetailComponent } from './order-detail/order-detail.component';


const routes: Routes = [
  { path: '', redirectTo: 'home', pathMatch: 'full' },
  { path: 'home', component: HomeComponent },
  { path: 'cake', component: CakeComponent },
  { path: 'bread', component: BreadComponent },
  { path: 'about', component: AboutComponent },
  {
    path: 'mine', component: MineComponent, children: [
      { path: '', component: WelcomeComponent },
      { path: 'collect', component: CollectComponent },
      { path: 'history', component: HistoryComponent },
      {
        path: 'transaction', component: TransactionComponent, children: [
          { path: 'myComment', component: MyCommentComponent },
          { path: 'myOrder', component: MyOrderComponent }
        ]
      },
      {
        path: 'information', component: InformationComponent, children: [
          { path: 'person', component: PersonComponent },
          { path: 'address', component: AddressComponent },
          { path: 'reset', component: ResetComponent }
        ]
      }
    ]
  },
  { path: 'orderDetail', component: OrderDetailComponent },
  { path: 'login', component: LoginComponent },
  { path: 'register', component: RegisterComponent },
  { path: 'cart', component: CartComponent },
  { path: 'order', component: OrderComponent },
  {
    path: 'details', component: DetailsComponent, children: [
      { path: '', redirectTo: 'detail', pathMatch: 'full' },
      { path: 'detail', component: DetailComponent },
      { path: 'comments', component: CommentComponent }
    ]
  },
  { path: '**', component: ErrorComponent }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule { }
